	
  <%@ page language="java" contentType="text/html" %>
	  				
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
		
  <html>
	  <head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>ajax example</title>
	  	<script type="text/javascript" src="./js/prototype.js"></script>
	  	<script type="text/javascript">
	  		var Form = {
	  			
	  			parameters : function(f) {
	  				var p = "", e;
	  				for (var i = 0; i < f.length; i++) {
	  					e = f[i];	  			
	  					if (i > 0)
	  						p += "&";
	  					
	  					if ((e.type == "checkbox" || e.type == "radio") && !e.checked)
	  						continue
	  						
	  					p += encodeURIComponent(e.name) + "=" + encodeURIComponent(e.value);	  					
	  				}
	  				
	  				return p;
	  			},
	  			
	  			submit : function(formElemente, framework) {
	  				var requestParams = this.parameters(formElemente);
	  				
	  				if (framework) {
						// mit Prototype
						new Ajax.Request("ajax.jsp", {
							method : 'POST',
							postBody : requestParams,
							onSuccess : 
								function(responseObject) {
									document.getElementById('server-reponse').innerHTML = responseObject.responseText;
								}
						});
							
					} else {
						// ohne Prototype
						// siehe: http://www.ajaxtoolbox.com/request/documentation.php
						var ajaxRequestObj = false;
						try { 
							ajaxRequestObj = new XMLHttpRequest();
						} catch (e){
							try { 
								ajaxRequestObj = new ActiveXObject('Msxml2.XMLHTTP');
							} catch (e){
								try { 
									ajaxRequestObj = new ActiveXObject('Microsoft.XMLHTTP');
								} catch (e){

								}
							}
						}

						if (ajaxRequestObj) {
							ajaxRequestObj.open("POST", "ajax.jsp");
							ajaxRequestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
							ajaxRequestObj.setRequestHeader("Content-length", requestParams.split("").length);

							ajaxRequestObj.onreadystatechange = 
								function () {
						          if (ajaxRequestObj.readyState == 4 && ajaxRequestObj.status == 200) {
						        	  document.getElementById('server-reponse').innerHTML = ajaxRequestObj.responseText;
						          }
						        }

							ajaxRequestObj.send(requestParams);
					    }
					}
	  				return false;
	  			}
	  			
	  		};
	  	</script>
	  </head>
	  <body>
	  	<form action="#" method="POST">
	  		<div id="server-reponse" style="float: right;">&nbsp;</div>
	  		<table cellpadding="2" cellspacing="2" border="0">
	  			<tbody>
		  			<tr>
		  				<td rowspan="2" valign="top">
		  					Verstanden?
		  				</td>
		  				<td>
					  		<input type="radio" name="gotit" checked value="yes" /> Ja
					  	</td>
		  			</tr>
		  			<tr>
		  				<td>
					  		<input type="radio" name="gotit" value="no" /> Nein
					  	</td>
					  </tr>
		  			<tr>
		  				<td valign="top">Eingabefeld</td>
		  				<td valign="top"><input type="text" name="inputfield" size="20" /></td>
		  			</tr>
		  			<tr>
		  				<td valign="top" colspan="2" align="right">
		  					<input type="submit" name="send" onclick="return Form.submit(this.form, true);" value="Senden (Framework)" />
		  					<input type="submit" name="send" onclick="return Form.submit(this.form, false);" value="Senden" />
		  				</td>
		  			</tr>
	  			</tbody>
	  		</table>
	  	</form>
	  </body>
  </html>
